home *** CD-ROM | disk | FTP | other *** search
/ Amiga Collections: Franz PD / Franz PD Disk #047 (1990)(Amiga User Group Deutschland e.V.)[v Disaster Master 2].zip / Franz PD Disk #047 (1990)(Amiga User Group Deutschland e.V.)[v Disaster Master 2].adf / A68K_Beispiele / ReadLn.asm < prev    next >
Assembly Source File  |  1989-07-02  |  2KB  |  72 lines

  1. ***************************************
  2. * ReadLn  - read one line of an       *
  3. *           Ascii file                *
  4. *                                     *
  5. * If the routine returns with d0 = 0  *
  6. * the file has been completely read   *
  7. *                                     *
  8. * written by E. Lenz                  *
  9. *            Johann-Fichte-Strasse 11 *
  10. *            8 Munich 40              *
  11. *            Germany                  *
  12. *                                     *
  13. ***************************************
  14.  
  15. ; INPUT
  16. ; d0 number of bytes in buffer
  17. ; a0 buffer pointer
  18. ; a1 begin of buffer            ( input buffer = 200 bytes )
  19. ; a2 where to write the line to ( output buffer = 200 bytes )
  20. ; a3 file handler
  21. ; a6 dos base
  22.  
  23. ; OUTPUT
  24. ; d0 new number of bytes in buffer
  25. ; d1 number of bytes read
  26. ; a0 new buffer pointer
  27.  
  28. _LVORead equ -$2a
  29.  
  30.         XDEF ReadLn
  31.  
  32. ReadLn     movem.l d2-d7/a1-a5,-(a7)
  33.  
  34.            moveq   #0,d1            no bytes read
  35.  
  36.            tst.l   d0
  37.            bne.s   nextGet
  38.            bsr.s   FillBuf
  39.            tst.l   d0
  40.            beq.s   nomore           no bytes left in file
  41.  
  42. nextGet    move.b  (a0)+,d2         transfer a byte
  43.            move.b  d2,(a2)+
  44.            addq.l  #1,d1            increment pointers
  45.            cmpi.l  #200,d1          do not write 
  46.            blt.s   noovf            beyond buffer
  47.            moveq   #0,d0
  48.            bra.s   nomore
  49. noovf      subq.l  #1,d0
  50.            bne.s   noFill
  51.            bsr.s   FillBuf
  52.            tst.l   d0
  53.            beq.s   nomore           no bytes left in file
  54. noFill     cmpi.b  #$a,d2
  55.            bne.s   nextGet
  56. nomore     movem.l (a7)+,d2-d7/a1-a5
  57.            rts
  58.  
  59. FillBuf    movem.l d1-d2/a1,-(a7)
  60.            move.l  a3,d1         fill buffer
  61.            move.l  a1,d2
  62.            move.l  #200,d3
  63.            jsr     _LVORead(a6)
  64.            cmpi.l  #-1,d0        treat error as zero bytes read
  65.            bne.s   isok
  66.            moveq   #0,d0
  67. isok       movem.l (a7)+,d1-d2/a1
  68.            movea.l a1,a0          buffer pointer = begin of buffer
  69.            rts
  70.            end
  71.  
  72.